# 多态 的基础: 继承+重写

class Feeder:

    def feed_animal(self, animal):
        print('饲养的动物的种类:', animal.name)
        animal.eat()


class Animal:

    def __init__(self, name):
        self.name = name

    def eat(self):
        print('animal  eat..')


feed1 = Feeder()
animal = Animal('dongwu')

feed1.feed_animal(animal)


#  Dog  Cat Sheep

class Dog(Animal):

    def eat(self):
        print('eat   wangwangwang.......')


class Cat(Animal):

    def eat(self):
        print('eat   miaomiao.......')


class Sheep(Animal):

    def eat(self):
        print('eat   mia 咩咩.......')


# 创建3 个动物子类的 实例
dog = Dog('哮天犬')
cat = Cat('kitty')
sheep = Sheep('多利')

feed1.feed_animal(dog)
feed1.feed_animal(cat)
feed1.feed_animal(sheep)


# python 是弱语言类型, 或动态语言类型


class Bird:

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def eat(self):
        print('bird  eat..  pupi')

    def fly(self):
        pass


# feed1.feed_animal(10)

bird = Bird('niao', 4)
feed1.feed_animal(bird)

# 鸭子 模式: 一个东西  看起来像鸭子, 加起来像鸭子, 走起来像鸭子
